#include "Vector2D.h"
#include "Circle.h"

void main()
{	
	//ADD//
	std::cout << "+++++ Vector2D tests +++++" << std::endl << std::endl;
	{
		std::cout << "Simple addition : u + (-u) = 0 : " ;
		Vector2D u = {9, -5};
		Vector2D v = {-9, 5};
		Vector2D answer = Vector2D::Add(u, v);
		Vector2D r = {0, 0};
		if(Vector2D::Equals(answer, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//SUB//
	{
		std::cout << "Simple soustraction : u - u = 0 : " ;
		Vector2D u = {9, 5};
		Vector2D answer = Vector2D::Substract(u, u);
		Vector2D r = {0, 0};
		if (Vector2D::Equals(answer, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//SCALE//
	{
		std::cout << "Simple Multiplication : u * 2 = 2u : " ;
		Vector2D u = {1, 1};
		Vector2D answer = Vector2D::Scale(u, 2);
		Vector2D r = {2, 2};
		if (Vector2D::Equals(answer, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}
	
	//MOVE//
	{
		std::cout << "Move U by -U : u + (-u) = 0 : " ;
		Vector2D u = {1, 1};
		Vector2D v = {-1, -1};
		Vector2D::MoveBy(v, u);
		Vector2D r = {0, 0};
		if (Vector2D::Equals(u, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//POLAR ANGLE//
	{
		std::cout << "Angle Polaire d'un vecteur : 0, 1 = 90 : " ;
		Vector2D u = {0, 1};
		float answer = Vector2D::GetPolarAngleDeg(u);
		float r = 90;
		if (fabs(answer - r) < EPSILON)
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//Angle Between Degrees
	{
		std::cout << "Angle Entre deux vecteur :(0,0) (0,1) = 90 : " ;
		Vector2D u = {0, 0};
		Vector2D v = {0, 1};
		float answer = Vector2D::AngleBetweenDeg(u, v);
		float r = 90;
		if (fabs(answer - r) < EPSILON)
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//LENGTH//
	{
		std::cout << "longeur d'un vecteur :(0,1) = 1 : " ;
		Vector2D u = {0, 1};
		float answer = Vector2D::Length(u);
		float r = 1;
		if (fabs(answer - r) < EPSILON)
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//LENGTH SQ//
	{
		std::cout << "longeur d'un vecteur au caree :(0,2) = 4 : " ;
		Vector2D u = {0, 2};
		float answer = Vector2D::LengthSq(u);
		float r = 4;
		if (fabs(answer - r) < EPSILON)
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//NORMALIZE//
	{
		std::cout << "vecteur normaliser :(0,5) = (0,1) : " ;
		Vector2D u = {0, 5};
		Vector2D::Normalize(u);
		Vector2D r = {0, 1};
		if (Vector2D::Equals(u, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//SCALE BY//
	{
		std::cout << "Scale d'un vecteur :(0,1) * 2 = (0,2) : " ;
		Vector2D u = {0, 1};
		Vector2D::ScaleBy(u, 2);
		Vector2D r = {0, 2};
		if (Vector2D::Equals(u, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//GET VECTOR BY ANGLE//
	{
		std::cout << "trouver un vecteur par un angle :90 = (0, 1) : " ;
		float u = 90;
		Vector2D answer = Vector2D::GetVectorByAngleDeg(u);
		Vector2D r = {0, 1};
		if (Vector2D::Equals(answer, r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	std::cout << "+++++ Circle tests +++++" << std::endl;

	//CONTAINS//
	{
		std::cout << "Contains test, Inside :0,0 is in 0,0 with 2 radius " ;
		Circle u = Circle(0, 0, 2);
		Vector2D r = {0, 0};
		if (u.Contains(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	{
		std::cout << "Contains test, Outside :10,10 isn't in 0,0 with 2 radius " ;
		Circle u = Circle(0, 0, 2);
		Vector2D r = {10, 10};
		if (!u.Contains(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//SET POSITION//

	{
		std::cout << "Set Pos test, 0,0 + 1,1 = 1,1 : " ;
		Circle u = Circle(0, 0, 2);
		Circle answer = Circle(1, 1, 2);
		Vector2D r = {1, 1};
		u.SetPosition(r);
		if (answer.Equals(u))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//COLIDES//

	{
		std::cout << "Colide Test 2 identical circles, colide : " ;
		Circle u = Circle(0, 0, 2);
		Circle r = Circle(0, 0, 2);
		if (u.CollidesWith(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	{
		std::cout << "Colide Test far away circle : " ;
		Circle u = Circle(0, 0, 2);
		Circle r = Circle(100, 100, 2);
		if (!u.CollidesWith(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	//RECTANGLE COLIDE//

	{
		std::cout << "Colide Test Circle/Rect same X/Y : " ;
		Circle u = Circle(0, 0, 2);
		Rectangle r = Rectangle(0, 0, 2, 2);
		if (u.CollidesWith(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	{
		std::cout << "Colide Test Circle/Rect Far away X/Y : " ;
		Circle u = Circle(0, 0, 2);
		Rectangle r = Rectangle(100, 100, 2, 2);
		if (!u.CollidesWith(r))
		{
			std::cout << "OK\n";
		}
		else
		{
			std::cout << "FAILED\n";
		}
	}

	system("pause");
}